<template>
    <input type="text" ref="myRef" />获取DOM元素
</template>

<script>
import { ref, onMounted } from 'vue';

export default {
    setup () {
        const myRef = ref(null);

        onMounted(() => {
            myRef.value.focus();
            console.log(myRef.value);
        });

        return {
            myRef,
        };
    },
};
</script>
